@extends("layout.admin")

@section("title")
    添加考试批次成员
@endsection

@section("content")
    <style>
        .help-block {
            display: block;
            margin-top: 5px;
            margin-bottom: 10px;
            color: #737373;
        }
    </style>
    <div class="layui-card-body">
        <div><h3>考场名称：{{$basic}}&nbsp;&nbsp;考试批次：{{$batch}}</h3></div>
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">用户名开通</li>
                <li><a href="{{route('admin.basic.membercreate.attach',['batch_id'=>request('batch_id'),'basic_id'=>request('basic_id'),'type'=>1])}}">条件开通</a></li>
            </ul>
            <div class="layui-tab-content" style="height: 100px;">
                <div class="layui-tab-item layui-show">
                    <form  style="margin-top: 15px;" class="layui-form" action="{{route('admin.basic.membercreate')}}">
                        @csrf
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-col-xs4" style="width: 540px;">
                                <input type="hidden" name="batch_id" value="{{request('batch_id')}}">
                                <input type="hidden" name="basic_id" value="{{request('basic_id')}}">
                                <textarea name="group" class="layui-textarea" rows="6"></textarea>
                                <div class="help-block">每个用户名请使用英文逗号隔开</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" lay-submit lay-filter="*">提交</button>
                                <a href="javascript:history.back(-1);" class="layui-btn layui-btn-primary">返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('script')
<script src="{{asset('layui/modules/xm-select.js')}}"></script>
<script src="{{asset('js/tree/select.js')}}"></script>
<script>
    var idx = -1;
    layui.use(['form','table','xmSelect'], function () {
        var table = layui.table;
        var form = layui.form,xmSelect = layui.xmSelect;
        table.init("table-hide");
        form.on("submit(*)", function (data) {
            var obj = $(this);
            obj.attr("disabled", "disabled").addClass("layui-disabled");
            $.post(data.form.action, data.field, function (data) {
                var icon = 5;
                if (data.code == "0") {
                    icon = 6;
                }
                layer.msg(data.msg, {icon: icon, time: 1500}, function () {   //提示的插件，可以使用alert代替
                    if (data.code==0) {
                        setTimeout(function () {
                            //刷新父页面
                            window.location.reload();
                        }, 500);
                    } else {
                        obj.removeAttr("disabled").removeClass("layui-disabled");
                    }
                });
            }, 'json');
            return false;
        });
    });
</script>
@endsection
